package com.ethan.http;

import android.widget.Toast;

import androidx.lifecycle.LifecycleOwner;

import com.ethan.rxretrofit.MainActivity;

import io.reactivex.rxjava3.core.Observable;

public class ApiReq {

   public static  <T extends BaseBean> void req(Observable<T> observable, LifecycleOwner lifecycleOwner,ApiCall<T> call){
        observable.compose(ApiFlowableTransformer.create(lifecycleOwner)).subscribe(r->{
            call.success(r);
        },e->{
            call.error(e);
        });
    }

    public static  <T extends BaseBean> void req(Observable<T> observable, LifecycleOwner lifecycleOwner,ApiCallSuccess<T> success,ApiCallError error){
        observable.compose(ApiFlowableTransformer.create(lifecycleOwner)).subscribe(r->{
            success.success(r);
        },e->{
            error.error(e);
        });

    }
}
